using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Browser;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using Lib.Helper;
using MSIACCSL2.ViewModels;
using WcfService1.DTO;

namespace MSIACCSL2.Views.DeliveryOrder
{
    public partial class Index : Page
    {
        public DeliveryOrderViewModel VM
        {
            get { return (DeliveryOrderViewModel)this.DataContext; }
        }

        public DeliveryOrderWrapViewModel WMW
        {
            get { return (this.Resources["POW"] as DeliveryOrderWrapViewModel); }
        }

        public Index()
        {
            InitializeComponent();
            DeliveryOrderViewModel.OnSearchCompleted = (x) =>
                                          {
                                              this.DataContext = (DeliveryOrderViewModel)x;
                                          };
        }

        private void btnPrint_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            //VM.Print((sender as Button).DataContext);
          
        }

        private void btnSend_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	VM.SendEmail((sender as Button).DataContext);
        }

        private void btnPrint_DO_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var DO = (sender as Button).DataContext as DeliveryOrderDTO;
            GlobalVar.OkaSocket.SendMessage("DeliveryOrder|" + DO.DONo);
            //MyButton button = new MyButton(GlobalVar.ReportUrl + "DO.aspx?no=" + HttpUtility.UrlEncode(DO.DONo));
            //button.ClickMe();
        }

    
    }
}


